﻿<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="JsonViewer.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:converters="clr-namespace:JsonViewer.Converters"
             xmlns:sl8="http://www.sl8.so"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <converters:JsonValueToVisualTextConverter x:Key="jsonValueToVisualTextConverter"/>
        <sdk:HierarchicalDataTemplate x:Key="TreeNodeDataTemplate" ItemsSource="{Binding Children}">
            <Grid Height="28">
                <Grid  VerticalAlignment="Center" Margin="3,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Foreground="Black" Text="{Binding PropertyName}" FontWeight="Bold"></TextBlock>
                    <TextBlock Grid.Column="1" Foreground="Black" Text=":"></TextBlock>
                    <TextBlock Grid.Column="2" Foreground="Black" Text="{Binding PropertyValue, Converter={StaticResource jsonValueToVisualTextConverter}}"></TextBlock>
                </Grid>
            </Grid>
        </sdk:HierarchicalDataTemplate>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid >
            <sl8:TiledImage SourceUri="/JsonViewer;component/Images/images-backgroundtexture.png"/>
            <Grid>
                <Grid.Background>
                    <ImageBrush ImageSource="/JsonViewer;component/Images/images-backgroundshadow.png"/>
                </Grid.Background>
            </Grid>
            <sl8:AppChromeControl Background="Transparent" x:Name="appChrome" AppIconImageSource="Images/json32.png" Title="JsonViewer">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="24"/>
                    </Grid.RowDefinitions>
                    <Grid Margin="12,0,12,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <Grid Grid.Column="0">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <!--json 输入框-->
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <TextBlock Text=" Json 字符串" Foreground="White" Margin="12,0,12,12"/>
                                <TextBox x:Name="txtSrcJson" Grid.Row="1"  VerticalAlignment="Stretch" AcceptsReturn="True"  TextWrapping="Wrap" HorizontalAlignment="Stretch"/>
                                <Grid Grid.Row="2" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right" Margin="6" >
                                        <Button Content="安装到本地" Height="32" Width="90" Margin="6,6,20,6" x:Name="btnInstall"/>
                                        <Button Content="转换" Height="32" Width="60" Margin="6,6,20,6" x:Name="btnViewJsonTree"/>
                                    </StackPanel>
                                </Grid>
                            </Grid>

                            <!--部分内容-->
                            <sdk:TabControl Grid.Row="2">
                                <sdk:TabItem Header="属性">
                                    <sdk:DataGrid x:Name="dgPropertys"/>
                                </sdk:TabItem>
                                <sdk:TabItem Header="Json">
                                    <TextBox x:Name="txtPropertyJson" IsReadOnly="True" TextWrapping="Wrap"/>
                                </sdk:TabItem>
                            </sdk:TabControl>
                        </Grid>

                        <!-- Json 对象树-->
                        <Grid Grid.Column="1" Margin="12,0,0,3">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <TextBlock Text=" Json 对象树" Foreground="White"  Margin="12,0,12,12"/>
                            <Grid Grid.Row="1">
                                <Border x:Name="OuterHighlight" BorderBrush="{StaticResource ControlOuterHighlightBrush}" BorderThickness="0,0,1,1" CornerRadius="3" Margin="0,0,-1,-1" />
                                <Border Background="{StaticResource InputBackgroundBrush}" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" CornerRadius="3" Margin="0">
                                    <sdk:TreeView Margin="12,0,12,12" x:Name="tvJsonTree" ItemsSource="{Binding}" ItemContainerStyle="{StaticResource ConnectingLinesTreeViewItem}"  ItemTemplate="{StaticResource TreeNodeDataTemplate}" />
                                </Border>
                                <!-- Inner Shadow. -->
                                <Border BorderBrush="{StaticResource InnerShadowDarkBrush}" BorderThickness="1,1,0,0" CornerRadius="2" Margin="1" />
                                <Border BorderBrush="{StaticResource InnerShadowLightBrush}" BorderThickness="1,1,0,0" CornerRadius="1" Margin="2,2,1,1" />

                            </Grid>
                        </Grid>
                    </Grid>
                    <StackPanel Grid.Row="1" Orientation="Horizontal"   HorizontalAlignment="Right">
                        <HyperlinkButton Margin="20,0,0,0" TargetName="_blank" HorizontalAlignment="Left" VerticalAlignment="Center" Content="支持:http://sl8.so" NavigateUri="http://sl8.so"/>
                        <TextBlock x:Name="txtVersionInfo" Margin="32,0" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                    </StackPanel>
                </Grid>
            </sl8:AppChromeControl>
        </Grid>
    </Grid>
</UserControl>
